Written by: Prograph International (Garth Smedley)
Contents: Floating Windows.pgs
Floating Window XPrims
Floating Window XPrims Library
Floating Windows.ReadMe
Needs Prograph Extensions:
Math Primitives
More Primitives
Primitives
Floating Window XPrims
Needs Libraries to Compile:
Floating Window XPrims Library
SCLibrary 2.6
Library 2.6
Standard Methods That Were Modified:
Universal Initial
Application/Notify
Application/Mouse Down
Menu/Quit
New Classes:
Regular Window
Floating Window
Pallette
Test Pallette
Test Window
Description
-----------
An example file with a special set of primitives that allows the use of "floating windows" in your Prograph program. Floating windows stay in front of all other active windows. A Palette class provides code for subdividing a window into a series of rectangles that invert when selected and remembers the last selection.
How to Use in Your Program
-------------------------
The classes "Floating Window", "Regular Window" and "Modal Window" have methods which keep floating windows afloat. Selectively load these classes into your file or use the example file as a starting point for your application. If you are adding floating windows to an existing file you will also have to selectively load "Application/Notify", "Application/Mouse Down", "Application/front" and "Menu/Quit". "Notify" and "Mouse Down" are changed to call "/front" instead of getting "front" directly, "front" is a get method and "Quit" has been changed to close all windows.
There are some rules you must follow in order to keep floating windows on top. All of your windows must be of class "Floating Window", "Regular Window" or "Modal Window" or a subclass of one of these. You must use the "/Open" and "/Close" methods to open and close windows; setting "active?" directly is not allowed. Because of this, you can't keep windows in the Application's active list since Prograph automatically sets "active?". Also, do not get or set the "front" attribute of Application directly; use "/front" to get the front window and "Regular Window/Bring To Front" to bring a window to the front.
To get a floating window with the title bar on the left, change the "def ID" attribute of your window from 3200 to 3202. To add or remove the close box set the "close?" attribute to TRUE or FALSE.
The example includes a class "Palette", a subclass of "Picture". Palette has two extra attributes, a list of rectangles and the currently selected rectangle. "Palette" selects a rectangle when its clicked in, and keeps the selected rectangle inverted. The classes "Test Window" and "Test Palette" demonstrate the use of "Palette" and floating windows.
More Details
------------
This example uses a set of external primitives (XPrims) to fool the Macintosh Window Manager into making windows float. The XPrims mirror normal window manager calls, they all start with "FW" usually followed by the name of the corresponding window manager routine.
FWSelectWindow - Replaces SelectWindow.
FWDragWindow - Replaces DragWindow.
FWHideWindow - Replaces HideWindow.
FWShowWindow - Replaces ShowWindow.
FWScanWindows - Returns front floater, bottom floater and front regular. Replaces FrontWindow.
FWHiliteAll - Floating windows usually stay hilited, except when the application is suspended or a modal dialog is opened. Unhilites all floaters.
FWOpenWindow - Allocates a window record and opens the window items.
A window definition function, (WDEF), is used to draw the title bar of the floating window. This WDEF is kept in the resource forks of the XPrim and XPrim library files and is automatically added to your application.